package dashboard.constant;

public enum EnumCity {
	total;
	public String getDBName(){
		switch (this) {
		case total :
			return "all";
		default:
			return "all";
		}
	}
	
	private static final String topNCon = "stat_date='%s' and (page_type='all' or page_type='detail') and business_name='%s' group by city_name";
	private static final String topNClos = "city_name,sum(if(page_type='all',?_pv,0)) as 'pv',sum(if(page_type='all',?_uv,0)) as 'uv',sum(if(page_type='detail',?_pv,0))/sum(if(page_type='all',?_uv,0)) as 'vppvDIVuv' ";
	
	public static String getTopNCon(EnumCate cateEnum,String stat_date){
		return String.format(topNCon, stat_date,cateEnum.getDBName());
	}
	
	public static String getTopNColumns(String platform){
		return topNClos.replace("?", platform);
	}
	
	private static final String UVClos = "sum(%s_uv) as 'uv' ";
	
	private static final String UVCon = "stat_date='%s' and business_name='%s' and city_name!='all' and page_type='all' group by %s";

	public static String getUVColumns(String platform){
		return String.format(UVClos, platform);
	}
	
	public static String getUVCon(String date,EnumCate cateEnum,String groupBy){
		return String.format(UVCon, date, cateEnum.getDBName(),groupBy);
	}
	
}
